package com.fyzk.activity.lottery.jc.beidan;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.fyzk.activity.app.ActivityTaskManager;
import com.fyzk.activity.app.App;
import com.fyzk.activity.app.AppToast;
import com.fyzk.activity.lottery.basketball.prizeoptimization.BdPrizeOptimizationActivity;
import com.fyzk.activity.lottery.basketball.prizeoptimization.JZPrizeOptimizationActivity;
import com.fyzk.activity.lottery.jc.football.JCInfo;
import com.fyzk.activity.lottery.jc.football.adapter.JCZQZhiFuBaseAdapter;
import com.fyzk.activity.lottery.jc.football.guoguan.JC_GuoGuanDialog;
import com.fyzk.activity.user.LoginActivity;
import com.fyzk.activity.zhifu.BetBaseActivity;
import com.fyzk.data.AppLotteryInfos;
import com.fyzk.data.preference.MySharedPreferences;
import com.fyzk.net.Constants;
import com.fyzk.net.PublicMethod;
import com.fyzk.utils.LogUtil;
import com.fyzk.utils.LogUtils;
import com.fyzk.utils.LotteryIDUtils;
import com.fyzk.utils.jc.BdGroupUtil;
import com.fyzk.utils.jc.BdPrizeComputeUtil;
import com.fyzk.view.ViewCallBack;
import com.tyjc.lottery.R;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.view.ASView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 竞彩支付的基类
 *
 * @author fxs
 * @time 2016年1月9日
 */
public abstract class BeiDanBasePayActivity extends BetBaseActivity implements GuoGuan_Pop.OnGuoGuanItemClickListener,
        BeiDanBasePayAdapter.OnBeiDanPayClickListerner, ASView.OnValueChangedLisener, BeiDan_BF_Pop.OnBeiDanBfPopListener {

    protected int wanFa = 1;

    // 其它
    protected final int oneAmount = 200;

    protected ListView listView;
    protected TextView guoGuan_tv;
    private GuoGuan_Pop guoGuan_pop;
    protected List<GuoGuanBean> guoGuanTypes = new ArrayList<>();

    public static ArrayList<BeiDanChildBean> pay_infors = new ArrayList<>();
    protected BeiDanBasePayAdapter adapter;
    private View shadow_unclick;

    private ASView touBei;
    private TextView addMore;

    private BeiDan_BF_Pop bf_pop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected View initCenterView() {

        lotteryId = getLotteryId();

        View view = LayoutInflater.from(getContext()).inflate(R.layout.beidan_pay, null);
        listView = view.findViewById(R.id.beidan_pay_listview);
        adapter = getAdapter();
        shadow_unclick = view.findViewById(R.id.shadow_unclick);
        shadow_unclick.setOnClickListener(this);
        listView.setAdapter(adapter);
        guoGuan_tv = view.findViewById(R.id.beidan_pay_ggfs);
        for (int i = 1; i <= getChangCi(); i++) {
            guoGuanTypes.add(new GuoGuanBean(i));
        }
        guoGuanTypes.get(guoGuanTypes.size() - 1).isCheck = true;
        guoGuan_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (getChangCi() == 0) {
                    AppToast.getToast().show(R.string.guoguan_bisai);
                } else {

                    if (guoGuan_pop == null) {
                        guoGuan_pop = new GuoGuan_Pop(getContext(), guoGuan_tv, guoGuanTypes, BeiDanBasePayActivity.this);
                    }
                    guoGuan_pop.showPopupWindow(guoGuan_tv, guoGuanTypes);
                }
            }
        });
        int chang = getChangCi();
        if (chang == 1) {
            guoGuan_tv.setText("单关");
        } else {
            guoGuan_tv.setText(getChangCi() + "串1");
        }


        int changci = pay_infors.size();
        if (guoGuan_tv.getText().equals("单关")) {
            isDanguan = true;
        } else {
            JC_GuoGuanDialog.isDuoChuan = false;
            JC_GuoGuanDialog.result = changci + "串" + 1;
        }
        touBei = view.findViewById(R.id.beidan_pay_et_toubei);
        touBei.setLeftText("投");
        touBei.setValue(1);
        touBei.setRightText("倍");
        touBei.setOnValueChangedLisener(this);

        addMore = view.findViewById(R.id.beidan_pay_center_addmore);
        addMore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });

        view.findViewById(R.id.zhifu_top_po).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                youhua();
            }
        });

        return view;
    }

    protected BeiDanBasePayAdapter getAdapter() {
        return null;
    }

    protected abstract int maxChuanCount();

    @Override
    public void onBackPressed() {
        setResult(getLotteryId());
        finish();//支付页退出不做任何操作
    }

    @Override
    public int getZhushu() {
        // TODO Auto-generated method stub
        return zhushu;
    }

    @Override
    public boolean isJC() {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public void lingAlert() {
        // TODO Auto-generated method stub
        if (guoGuan_tv.getText().toString().equals(getString(R.string.guoguan_hint))) {
            AppToast.getToast().show(R.string.guoguan_hint);
        } else {
            AppToast.getToast().show(R.string.guoguan_bisai);
        }

    }

    @Override
    protected boolean hemaiAble() {
        // TODO Auto-generated method stub
        if ((isDanguan) || getZhushu() < 10000) {
            return true;
        }
        AppToast.getToast().show("过关投注单倍最大投注彩金不能超过20000米！");
        return false;
    }


    @Override
    public String getBetCode() {
        return "";
    }

    /**
     * 获取期号
     *
     * @return
     */
    public String getPhase() {
        return getIntent().getStringExtra(IntentParamUtils.ZC_PHASE);
    }

    private int getChangCi() {
        int changCi = 0;
        for (int i = 0; i < pay_infors.size(); i++) {
            if (pay_infors.get(i).isChecked()) {
                changCi++;
            }
        }
        if (changCi > maxChuanCount()) {
            changCi = maxChuanCount();
        }
        return changCi;
    }

    @Override
    public void onGuoGuanItemClick(List<GuoGuanBean> types) {
        String guoGuanStr = "";
        for (int i = 0; i < types.size(); i++) {
            if (types.get(i).isCheck) {
                guoGuanStr += types.get(i).typeName + ",";
            }
        }
        if (guoGuanStr.length() > 0) {
            guoGuanStr = guoGuanStr.substring(0, guoGuanStr.length() - 1);
        } else {
            guoGuanStr = App.getContext().getResources().getString(R.string.guoguan_hint);
        }
        guoGuan_tv.setText(guoGuanStr);
        jiShuan();
    }

    @Override
    public void onItemClick() {
        int chuan_Count = getChangCi();
        int chuan_Count_old = guoGuanTypes.size();

        if (chuan_Count == 0) {
            guoGuanTypes.clear();
            onGuoGuanItemClick(guoGuanTypes);
        } else {
            if (chuan_Count == chuan_Count_old) {
                jiShuan();
                return;
            } else if (chuan_Count < chuan_Count_old) {
                List<GuoGuanBean> guoGuanTypes_new = new ArrayList<>();
                for (int i = 0; i < chuan_Count; i++) {
                    guoGuanTypes_new.add(guoGuanTypes.get(i));
                }
                guoGuanTypes = guoGuanTypes_new;
                boolean isCheck = false;
                for (int j = 0; j < guoGuanTypes.size(); j++) {
                    if (guoGuanTypes.get(j).isCheck) {
                        isCheck = true;
                    }
                }
                if (!isCheck) {
                    guoGuanTypes.get(guoGuanTypes.size() - 1).isCheck = true;
                }
            } else {
                int endNum = 1;
                if (guoGuanTypes.size() > 0) {
                    endNum = guoGuanTypes.get(chuan_Count_old - 1).changCiCount + 1;
                }
                for (int i = endNum; i < endNum + (chuan_Count - chuan_Count_old); i++) {
                    guoGuanTypes.add(new GuoGuanBean(i));
                }
                if (guoGuanTypes.size() == 1) {
                    guoGuanTypes.get(0).isCheck = true;
                }
            }
            onGuoGuanItemClick(guoGuanTypes);
        }
    }

    public void jiShuan() {
        List<Integer> clicknums = new ArrayList<>();
        List<Boolean> dannums = new ArrayList<>();
        for (int i = 0; i < pay_infors.size(); i++) {
            BeiDanChildBean bean = pay_infors.get(i);
            if (bean.checkNum > 0) {
                clicknums.add(bean.checkNum);
                dannums.add(bean.isDan);
            }
        }
        this.zhushu = 0;
        for (int i = 0; i < guoGuanTypes.size(); i++) {
            GuoGuanBean guoGuanBean = guoGuanTypes.get(i);
            if (guoGuanBean.isCheck) {
                this.zhushu += BeiDanBetNumUtil.getZhushu(guoGuanBean.changCiCount, clicknums, dannums);
            }
        }
    }

    @Override
    public void setBtmView() {
        Log.e("fjl", pay_infors.size() + "---------");
        btm_zhu.setText(getZhushu() + "注");
        btm_money.setText(getMoney() + getString(R.string.zhifu_danwei));
        btm_bei.setText(getBeishu() + "倍");
        if (pay_infors != null && pay_infors.size() > 0) {
            System.out.println(JSON.toJSON(pay_infors).toString());
            BdPrizeComputeUtil util = new BdPrizeComputeUtil(this, pay_infors, lotteryId);
            if (getZhushu() > 0) {
                shadow_unclick.setVisibility(View.VISIBLE);
                PrizeAsyncTask prizeAsyncTask = new PrizeAsyncTask();
                prizeAsyncTask.execute(util);
            } else {
                btm_leftMoney.setText("至少选择一注");
            }
        }
    }

    @Override
    public int getOneAmount() {
        return 2;
    }

    @Override
    public void onValueChanged(ASView view, int value) {
        beishu = value;
        if (beishu < 1) {
            beishu = 1;
        }
        setBtmView();
    }

    @Override
    public int getBeishu() {
        return touBei.getValue();
    }

    @Override
    protected void adapterChange() {
        adapter.setInfors(pay_infors);
    }

    @Override
    protected void clear() {
        for (int i = 0; i < pay_infors.size(); i++) {
            pay_infors.get(i).clearAll();
        }
        adapterChange();
    }

    @Override
    public void onZhanKaiClick(BeiDanChildBean infor) {
        if (bf_pop == null) {
            bf_pop = new BeiDan_BF_Pop(getContext(), infor, this);
        }
        bf_pop.showPopupWindow(btm_sure, infor);
    }

    @Override
    public void onSureClick() { // 比分pop 确定按钮点击事件
        adapter.notifyDataSetChanged();
    }


    protected void youhua() {
        if (!MySharedPreferences.getInstance().getLoginStatus()) {
            AppLotteryInfos.clear();
            ViewCallBack.getInstance().countDownObjs.clear();
            ActivityTaskManager.getInstance().closeAllActivity();
            Intent intent = new Intent(getContext(), LoginActivity.class);
            startActivity(intent);
        } else {
            if (JC_GuoGuanDialog.isDuoChuan) {
                showToast("奖金优化不支持多串");
                return;
            }

            boolean isDanTuo = false;
            for (BeiDanChildBean info : pay_infors) {
                if (info.isDan()) {
                    isDanTuo = true;
                    break;
                }
            }
            String ggfs = guoGuan_tv.getText().toString();

            if (isDanTuo) {
                showToast("奖金优化不支持胆拖");
            } else if (ggfs.contains("串") || ggfs.equals("单关")) {
                if (getZhushu() <= Constants.MAX_PO_ZHU) {
                    Intent intent = new Intent(this, BdPrizeOptimizationActivity.class);
                    intent.putExtra("chuanguan", ggfs);
                    intent.putExtra("zhushu", getZhushu() * getBeishu());
                    intent.putExtra("minprize", minPrize);
                    intent.putExtra(IntentParamUtils.LOTTERYID, lotteryId);
                    startActivityForResult(intent, IntentParamUtils.TO_PO);
                } else {
                    showToast("注数大于" + Constants.MAX_PO_ZHU + "注时无法进行奖金优化");
                }
            } else {
                showToast(R.string.guoguan_hint);
            }
        }
    }

    private String typeStrs[] = null;

    class PrizeAsyncTask extends AsyncTask<BdPrizeComputeUtil, String, String> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected String doInBackground(BdPrizeComputeUtil... util) {
            try {
                double prizeMax = 0.0;
                double prizeMin = 0.0;
                if (isDanguan) {//单关
                    prizeMin = util[0].getDanPrize(false);
                    prizeMax = util[0].getDanPrize(true);
                } else {//过关
                    if (JC_GuoGuanDialog.isDuoChuan) {
                        typeStrs = JC_GuoGuanDialog.duo_result.split("\\,");
                        int teamNum = JC_GuoGuanDialog.team_num;
                        if (null != typeStrs) {
                            // 存放最小预计彩金
                            List<Double> prizeMinData = new ArrayList<>();

                            LogUtils.e("====infos===="+pay_infors.size());

                            List<ArrayList<BeiDanChildBean>> groupInfoDataMax = getGroupInfoData(pay_infors, teamNum, false);
                            List<ArrayList<BeiDanChildBean>> groupInfoDataMin = getGroupInfoData(pay_infors, teamNum, true);

                            for(int j=0;j<groupInfoDataMax.size();j++){
                                ArrayList<BeiDanChildBean> childInfoData = groupInfoDataMax.get(j);
                                for (int i = 0; i < typeStrs.length; i++) {
                                    if (typeStrs[i].contains("串")) {
                                        prizeMax += util[0].getDoublePrize2(typeStrs[i], childInfoData, true);
                                    }
                                }
                            }

                            for (int j = 0; j < groupInfoDataMin.size(); j++) {
                                ArrayList<BeiDanChildBean> childInfoData = groupInfoDataMin.get(j);
                                for (int i = 0; i < typeStrs.length; i++) {
                                    if (typeStrs[i].contains("串")) {
                                        double tempMinPrize = util[0].getDoublePrize2(typeStrs[i], childInfoData, false);
                                        prizeMinData.add(tempMinPrize);
                                    }
                                }
                            }
                            // 获取集合中最小的预计彩金
                            for (int i=0;i<prizeMinData.size();i++){
                                double prize = prizeMinData.get(i);
                                if(Collections.min(prizeMinData) == prize){
                                    prizeMin += prize;
                                }
                            }
                        }
                    } else {
                        typeStrs = JC_GuoGuanDialog.result.split("\\,");
                        if (null != typeStrs) {
                            for (int i = 0; i < typeStrs.length; i++) {
                                if (typeStrs[i].contains("串")) {
                                    prizeMax += util[0].getDoublePrize(typeStrs[i], true);
                                    if (prizeMin == 0) {
                                        prizeMin = util[0].getDoublePrize(typeStrs[i], false);
                                    }
                                }
                            }
                        }
                    }
                }
                minPrize = prizeMin * getBeishu() * 0.65;
                double maxPrize = prizeMax * getBeishu() * 0.65;
                maxBounusPrize = maxPrize;
                if (minPrize > maxPrize) {
                    minPrize = maxPrize;
                }
                String prizeMinStr = PublicMethod.formatMoney(minPrize * 100);
                String prizeMaxStr = PublicMethod.formatMoney(maxPrize * 100);
                StringBuffer prizeB = new StringBuffer();
                if (prizeMinStr.equals(prizeMaxStr)) {
                    prizeB.append(prizeMinStr);
                    expectedPrize = prizeMinStr;
                } else {
                    prizeB.append(prizeMinStr);
                    prizeB.append("~");
                    prizeB.append(prizeMaxStr);
                    expectedPrize = prizeMinStr + "~" + prizeMaxStr;
                }
                return prizeB.toString();
            }catch (Exception e){
                return "计算失败";
            }

        }

        @Override
        protected void onPostExecute(String o) {
            super.onPostExecute(o);
            shadow_unclick.setVisibility(View.GONE);
            LogUtil.v("计算完了，展示计算结果");
            String infoStr = "预计奖金：<font color='#fd4a4a'>" + o + "</font>米";
            btm_leftMoney.setText(Html.fromHtml(infoStr));
        }
    }


    // 用于临时存放K场次M串，排列组合方式信息
    public List<ArrayList<BeiDanChildBean>> tempGroupData;

    private List<ArrayList<BeiDanChildBean>> getGroupInfoData(ArrayList<BeiDanChildBean> infos, int teamNum, boolean isMin) {
        List<ArrayList<BeiDanChildBean>> groupInfoData;
        switch (lotteryId) {
            //胜平负过关投注方式
            case LotteryIDUtils.JZSPFRSPF_LOTTERY_ID_INT:
                if (isMin) {
                    groupInfoData = getSPFGroupInfoData(infos, teamNum, isMin);
                } else {
                    ArrayList<BeiDanChildBean> spfInfos = BdGroupUtil.clone(infos);
                    BdGroupUtil.initSPFInfos(spfInfos);
                    groupInfoData = getSPFGroupInfoData(spfInfos, teamNum, isMin);
                }
                break;
            //混合过关投注方式
            case LotteryIDUtils.JZHH_LOTTERY_ID_INT:
                if (isMin) {
                    groupInfoData = getHGGroupInfoData(infos, teamNum, isMin);
                } else {
                    ArrayList<BeiDanChildBean> hgInfos = BdGroupUtil.clone(infos);
                    BdGroupUtil.initHGInfos(hgInfos);
                    groupInfoData = getHGGroupInfoData(hgInfos, teamNum, isMin);
                }
                break;
            //其他过关投注方式（半全场、比分、总进球）
            default:
                groupInfoData = getOtherGroupInfoData(infos, teamNum);
                break;
        }
        return groupInfoData;
    }

    /**
     * 胜平负投注数据分组处理
     *
     * @param infos
     * @param teamNum
     * @param isMin
     * @return
     */
    private List<ArrayList<BeiDanChildBean>> getSPFGroupInfoData(ArrayList<BeiDanChildBean> infos, int teamNum, boolean isMin) {
        List<ArrayList<BeiDanChildBean>> groupInfoData = new ArrayList<>();
        // 保存设置为胆的比赛场次信息
        ArrayList<BeiDanChildBean> danInfoData = new ArrayList<>();
        // 保存不是胆的比赛场次信息
        ArrayList<BeiDanChildBean> noDanInfoData = new ArrayList<>();

        // 例如选择8场比赛，8串n过关方式
        if (infos.size() == teamNum) {
            if (isMin) {
                groupInfoData.add(infos);
            } else {
                groupInfoData = BdGroupUtil.convert(infos, teamNum);
            }
            LogUtils.e("====groupInfoData====" + groupInfoData.toString());
        } else {
            for (int i = 0; i < infos.size(); i++) {
                BeiDanChildBean tempInfo = infos.get(i);
                int checkNum = tempInfo.checkNum;
                if (checkNum > 0) {
                    if (tempInfo.isDan()) {
                        // 找出设为胆的比赛场次
                        danInfoData.add(tempInfo);
                    } else {
                        // 找出不是胆的场次
                        noDanInfoData.add(tempInfo);
                    }
                }
            }
            getGroupSort(noDanInfoData, teamNum - danInfoData.size());

            LogUtils.e("====tempGroupData====" + tempGroupData.toString());

            for (int i = 0; i < tempGroupData.size(); i++) {
                ArrayList<BeiDanChildBean> tempInfoData = tempGroupData.get(i);
                // 将作为胆的比赛场次信息添加到每一个排列信息中
                tempInfoData.addAll(danInfoData);
                if (isMin) {
                    groupInfoData.add(tempInfoData);
                } else {
                    List<ArrayList<BeiDanChildBean>> groupInfoData1 = BdGroupUtil.convert(tempInfoData, teamNum);
                    groupInfoData.addAll(groupInfoData1);
                }
            }
        }
        return groupInfoData;
    }

    /**
     * 混合过关投注数据分组处理
     *
     * @param infos
     * @param teamNum
     * @param isMin
     * @return
     */
    private List<ArrayList<BeiDanChildBean>> getHGGroupInfoData(ArrayList<BeiDanChildBean> infos, int teamNum, boolean isMin) {
        List<ArrayList<BeiDanChildBean>> groupInfoData = new ArrayList<>();
        // 保存设置为胆的比赛场次信息
        ArrayList<BeiDanChildBean> danInfoData = new ArrayList<>();
        // 保存不是胆的比赛场次信息
        ArrayList<BeiDanChildBean> noDanInfoData = new ArrayList<>();
        // 例如选择8场比赛，8串n过关方式
        if (infos.size() == teamNum) {
            if (isMin) {
                groupInfoData.add(infos);
            } else {
                groupInfoData = BdGroupUtil.convert(infos, teamNum);
            }
        } else {
            for (int i = 0; i < infos.size(); i++) {
                BeiDanChildBean tempInfo = infos.get(i);
                int checkNum = tempInfo.checkNum;
                if (checkNum > 0) {
                    if (tempInfo.isDan()) {
                        // 找出设为胆的比赛场次
                        danInfoData.add(tempInfo);
                    } else {
                        // 找出不是胆的场次
                        noDanInfoData.add(tempInfo);
                    }
                }
            }
            getGroupSort(noDanInfoData, teamNum - danInfoData.size());

            LogUtils.e("====tempGroupData====" + tempGroupData.toString());

            for (int i = 0; i < tempGroupData.size(); i++) {
                ArrayList<BeiDanChildBean> tempInfoData = tempGroupData.get(i);
                // 将作为胆的比赛场次信息添加到每一个排列信息中
                tempInfoData.addAll(danInfoData);
                if (isMin) {
                    groupInfoData.add(tempInfoData);
                } else {
                    List<ArrayList<BeiDanChildBean>> groupInfoData1 = BdGroupUtil.convert(tempInfoData, teamNum);
                    groupInfoData.addAll(groupInfoData1);
                }
            }
        }
        return groupInfoData;
    }

    private List<ArrayList<BeiDanChildBean>> getOtherGroupInfoData(ArrayList<BeiDanChildBean> infos, int teamNum) {
        List<ArrayList<BeiDanChildBean>> groupInfoData = new ArrayList<>();
        // 保存设置为胆的比赛场次信息
        ArrayList<BeiDanChildBean> danInfoData = new ArrayList<>();
        // 保存不是胆的比赛场次信息
        ArrayList<BeiDanChildBean> noDanInfoData = new ArrayList<>();
        // 例如选择8场比赛，8串n过关方式
        if (infos.size() == teamNum) {
            groupInfoData.add(infos);
        } else {
            for (int i = 0; i < infos.size(); i++) {
                BeiDanChildBean tempInfo = infos.get(i);
                int checkNum = tempInfo.checkNum;
                if (checkNum > 0) {
                    if (tempInfo.isDan()) {
                        // 找出设为胆的比赛场次
                        danInfoData.add(tempInfo);
                    } else {
                        // 找出不是胆的比赛场次
                        noDanInfoData.add(tempInfo);
                    }
                }
            }
            getGroupSort(noDanInfoData, teamNum - danInfoData.size());

            LogUtils.e("====tempGroupData====" + tempGroupData.toString());

            for (int i = 0; i < tempGroupData.size(); i++) {
                ArrayList<BeiDanChildBean> tempInfoData = tempGroupData.get(i);
                // 将作为胆的比赛场次信息添加到每一个排列信息中
                tempInfoData.addAll(danInfoData);
                groupInfoData.add(tempInfoData);
            }
        }
        return groupInfoData;
    }

    /**
     * K场次M串排列组合方式
     * 例如 通常请款下（不加胆时）：选择8场比赛，3串n过关方式，
     * 8场中任选3场有56种情况
     *
     * @param info    选择的场次信息
     * @param teamNum M串 M的数量
     */
    public void getGroupSort(ArrayList<BeiDanChildBean> info, int teamNum) {
        tempGroupData = new ArrayList<>();
        if (info == null || info.size() == 0) {
            return;
        }
        ArrayList<BeiDanChildBean> list = new ArrayList();
        combine(info, 0, teamNum, list);
    }

    // 从字符数组中第begin个字符开始挑选number个字符加入list中
    public void combine(ArrayList<BeiDanChildBean> info, int begin, int number, ArrayList<BeiDanChildBean> list) {
        if (number == 0) {
            // 将每一种排列组合结果保存在tempGroupData中
            tempGroupData.add(new ArrayList<BeiDanChildBean>(list));
            return;
        }
        if (begin == info.size()) {
            return;
        }
        list.add(info.get(begin));
        combine(info, begin + 1, number - 1, list);
        list.remove(info.get(begin));
        combine(info, begin + 1, number, list);
    }
}
